import React,{Component} from 'react';
import {connect} from 'react-redux';
import { fetchList} from "../actions"
import { Table } from 'antd';
import { Button} from 'antd';

const mapStateToProps=(state)=>{
    return{
        cart:state.carts
    }
}
 class Product extends Component{
    constructor(){
        super()
        this.state={
            number:0
        }
    }
    render(){
        const columns = [{
            title: '名称',
            dataIndex: 'title',
            render: text => <a href="javascript:;">{text}</a>,
          }, {
            title: '图片',
            className: 'column-money',
            dataIndex: 'img',
            render: text => <img src={text} style={{width:"80px", height:"80px"}}></img>
          },  {
            title: '介绍',
            className: 'column-money',
            dataIndex: 'content',
          },{
            title: '价格',
            className: 'column-money',
            dataIndex: 'stars.number',
            render: text => <span>￥{text}</span>
          },{
            title: '数量',
            className: 'column-money',
            dataIndex: 'quantity',
            render: text => <span>{text}个</span>
          }];
        return(
            <div>
            <Table
            columns={columns}
            dataSource={this.props.cart}
            bordered
          />
          <strong>总价格:</strong>
          <Button type="primary" block>提交订单</Button>
          </div>
        )
    }
}

export default connect(mapStateToProps,{fetchList})(Product);